package theone.ui;

import org.newdawn.slick.Font;
import org.newdawn.slick.Image;

public class UiButton extends UiCompositeComponent {
	
	private UiPanel background;
	private UiLabel text;
	
	public UiButton(Image wood_background, Image[] images, Font font_text, String text) {

		background = new UiPanel(wood_background, images);
		background.setHoverSensitive(true);
		background.setX(0);
		background.setY(0);
		add(background);

		this.text = new UiLabel(font_text, text);
		this.text.setHoverSensitive(true);
		this.text.setX(0);
		this.text.setY(0);
		add(this.text);
	}
	
	
	/*public void draw(Graphics g, int offsetX, int offsetY) {
		
		Color currentColor = Faded;
		if (isHover())
		{
			currentColor = Bright;
		}
		
		// Draw background
		g.drawImage(back, offsetX + getX(), offsetY + getY(), currentColor);
		
		// Draw text
		g.setFont(font);
		g.setColor(currentColor);
		g.drawString(text, offsetX + getX() + ((getWidth() - font.getWidth(text))/2), 
				offsetY + getY() + ((getHeight() - font.getHeight(text))/2));
		
	}*/
	
	public void setText(String text_str) {
		text.setText(text_str);
	}

	@Override
	public void setWidth(int width) {
		super.setWidth(width);
		
		background.setWidth(width);
		text.setWidth(width);
	}

	@Override
	public void setHeight(int height) {
		super.setHeight(height);
		
		background.setHeight(height);
		text.setHeight(height);
	}
}
